package cn.webrx;

import java.io.FileInputStream;
import java.io.ObjectInputStream;

public class UserDemo {
    public static void main(String[] args) {

        //try(ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("u.dat")) ){
        //    //oos.writeObject(u);
        //    //List<String> list = List.of("java","php");
        //    //oos.writeObject(list);
        //    User user = new User(10,"李四");
        //    oos.writeObject(user);
        //}catch(Exception e){
        //    e.printStackTrace();
        //}


        try(var ois = new ObjectInputStream(new FileInputStream("u.dat"))){
            Object obj = ois.readObject();
            User u = (User)obj;
            System.out.println(u);
            System.out.println(u.getId());
            System.out.println(u.getName());
        }catch(Exception e){
            e.printStackTrace();
        }
    }
}
